package com.zxl.live.screen.call.ui.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;

public class FixRatioImageView extends ImageView {
    private float a = 1.0F;

    public FixRatioImageView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public FixRatioImageView(Context context, AttributeSet attributeSet, int defStyleAttr) {
        super(context, attributeSet, defStyleAttr);
    }

    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int i = MeasureSpec.getSize(widthMeasureSpec);
        if (this.a >= 0.0F) {
            heightMeasureSpec = MeasureSpec.makeMeasureSpec((int) Math.ceil(i / this.a), Integer.MIN_VALUE);
        }
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }

    public void setAspectRatioAndInvalidate(float paramFloat) {
        this.a = paramFloat;
        invalidate();
    }
}
